//
//  MapSegmentViewController.m
//  LZMPro
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 LZS. All rights reserved.
//

#import "MapSegmentViewController.h"
#import "MapDestinationViewController.h"
#import "TravelViewController.h"
@interface MapSegmentViewController ()

@property (nonatomic, retain) UISegmentedControl *segment;

@end

@implementation MapSegmentViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
}
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.segment addTarget:self action:@selector(changeController:) forControlEvents:UIControlEventValueChanged];
    
    [self addMyChildController];
}

-(void)changeController:(UISegmentedControl *)seg
{
    NSArray *array = self.view.subviews;
    [self.view bringSubviewToFront:array[0]];
}

-(void)addMyChildController
{
    MapDestinationViewController *destination = [[MapDestinationViewController alloc]init];
    [self addChildViewController:destination];
    [self.view addSubview:destination.view];
    
    
    TravelViewController *recommend = [[TravelViewController alloc]init];
    [self addChildViewController:recommend];
    [self.view addSubview:recommend.view];
    
}

-(UISegmentedControl *)segment
{
    if (_segment == nil) {
        
         NSArray *array = @[@"推荐",@"目的地"];
        _segment = [[UISegmentedControl alloc]initWithItems:array];
        [_segment setMyFramewithX:0 andY:0 andWidth:150 andHeight:30];
        _segment.centerX = self.view.centerX;
        self.navigationItem.titleView = _segment;
        _segment.selectedSegmentIndex = 0;
       _segment.tintColor = [UIColor orangeColor];
       _segment.alpha = 0.5;

        
    }
    
    
    return  _segment;
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
